public class College {
    // 私有属性
    private Building building;
    private List<Course> courses;

    // 构造方法
    public College(Building building) {
        this.building = building;
        this.courses = new ArrayList<>();
    }

    // 添加课程的方法
    public void addCourse(Course course) {
        if (course.getBuilding() == this.building) {
            courses.add(course);
        } else {
            throw new IllegalArgumentException("Course must be in the same building as the college.");
        }
    }

    // 获取所有课程的方法
    public List<Course> getCourses() {
        return courses;
    }

    // 获取建筑的方法
    public Building getBuilding() {
        return building;
    }
}

public class Building {
    // 私有属性
    private String name;

    // 构造方法
    public Building(String name) {
        this.name = name;
    }

    // 获取建筑名称的方法
    public String getName() {
        return name;
    }
}

public class Course {
    // 私有属性
    private String name;
    private Building building;

    // 构造方法
    public Course(String name, Building building) {
        this.name = name;
        this.building = building;
    }

    // 获取课程名称的方法
    public String getName() {
        return name;
    }

    // 获取课程所在建筑的方法
    public Building getBuilding() {
        return building;
    }
}
